package com.cwz.logo;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

public class DataProvider {
	private static final String xmlUrl = "http://www.google.com.hk/logos/logos.xml";
	private static Map<String, String> map = new HashMap<String, String>();

	public static Map<String, String> getMap() {
		return map;
	}

	public static void setMap(Map<String, String> map) {
		DataProvider.map = map;
	}

	public static void getData() {
		SAXParserFactory factory = SAXParserFactory.newInstance();
		try {
			SAXParser parser = factory.newSAXParser();
			XMLReader reader = parser.getXMLReader();
			URL url = new URL(xmlUrl);
			InputSource is = new InputSource(url.openStream());
			reader.setContentHandler(new SAXHandler());
			reader.parse(is);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
